package cn.imnaer.service.rest.view.model;

import java.util.ArrayList;
import java.util.List;

import cn.imnaer.service.rpc.enums.EnumFriendCircleType;

public class FriendMessage {
	private String friendMessageId;
	/**
	 * 朋友圈类目类型 travelNote, sharePhoto
	 * 
	 * @see cn.imnaer.service.rpc.enums.EnumFriendCircleType
	 */
	private String type;
	private String name;
	private String friendUserId;
	private String friendName;
	/**
	 * 图片类型 food,fun,stay
	 * 
	 * @see cn.imnaer.service.rpc.enums.EnumScenicType
	 */
	private String photoType;
	private String image;
	private int placeCount;
	private int dayCount;
	private int supportCount;
	private int commentCount;
	private long createTime;

	public FriendMessage parse(SharePhotoResponse sharePhotoResponse) {
		this.friendMessageId = sharePhotoResponse.getSharePhotoId();
		this.type = EnumFriendCircleType.SHARE_PHOTO.getValue();
		this.name = sharePhotoResponse.getSharePhotoName();
		this.friendUserId = sharePhotoResponse.getUserId();
		this.friendName = sharePhotoResponse.getUserName();
		this.photoType = sharePhotoResponse.getType();
		this.image = sharePhotoResponse.getItems().get(0).getImage();
		this.supportCount = sharePhotoResponse.getSupportCount();
		this.commentCount = sharePhotoResponse.getCommentCount();
		this.createTime = sharePhotoResponse.getCreateTime();
		return this;
	}

	public FriendMessage parse(TravelNoteDetail travelNoteDetail) {
		this.friendMessageId = travelNoteDetail.getTravelNoteId();
		this.type = EnumFriendCircleType.TRAVEL_NOTE.getValue();
		this.name = travelNoteDetail.getTravelNoteName();
		this.friendUserId = travelNoteDetail.getUserId();
		this.image = travelNoteDetail.getTravelNotePhotos().get(0).getImage();
		this.createTime = travelNoteDetail.getCreateTime();
		this.placeCount = travelNoteDetail.getPlaceCount();
		this.dayCount = travelNoteDetail.getDayCount();
		return this;
	}

	public static List<FriendMessage> parseSharePhotoResponseToList(List<SharePhotoResponse> sharePhotoResponseList) {
		List<FriendMessage> result = new ArrayList();
		for (SharePhotoResponse sharePhotoResponse : sharePhotoResponseList) {
			FriendMessage item = new FriendMessage().parse(sharePhotoResponse);
			result.add(item);
		}
		return result;
	}

	public static List<FriendMessage> parseTravelNoteToList(List<TravelNoteDetail> travelNoteList) {
		List<FriendMessage> result = new ArrayList();
		for (TravelNoteDetail travelNoteDetail : travelNoteList) {
			FriendMessage item = new FriendMessage().parse(travelNoteDetail);
			result.add(item);
		}
		return result;
	}

	/**************************************************************************************************************************************************************************************/

	public String getFriendMessageId() {
		return friendMessageId;
	}

	public void setFriendMessageId(String friendMessageId) {
		this.friendMessageId = friendMessageId;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getFriendUserId() {
		return friendUserId;
	}

	public void setFriendUserId(String friendUserId) {
		this.friendUserId = friendUserId;
	}

	public String getFriendName() {
		return friendName;
	}

	public void setFriendName(String friendName) {
		this.friendName = friendName;
	}

	public String getPhotoType() {
		return photoType;
	}

	public void setPhotoType(String photoType) {
		this.photoType = photoType;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public int getPlaceCount() {
		return placeCount;
	}

	public void setPlaceCount(int placeCount) {
		this.placeCount = placeCount;
	}

	public int getDayCount() {
		return dayCount;
	}

	public void setDayCount(int dayCount) {
		this.dayCount = dayCount;
	}

	public int getSupportCount() {
		return supportCount;
	}

	public void setSupportCount(int supportCount) {
		this.supportCount = supportCount;
	}

	public int getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(int commentCount) {
		this.commentCount = commentCount;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	@Override
	public String toString() {
		return "FriendMessage [friendMessageId=" + friendMessageId + ", type=" + type + ", name=" + name
				+ ", friendUserId=" + friendUserId + ", friendName=" + friendName + ", photoType=" + photoType
				+ ", image=" + image + ", placeCount=" + placeCount + ", dayCount=" + dayCount + ", supportCount="
				+ supportCount + ", commentCount=" + commentCount + ", createTime=" + createTime + "]";
	}

}
